#include <iostream>
#include "hessian/HttpConnection.h"
#include "test/IServiceProxy.h"
#include <sys/time.h>
using namespace std;

int main(int argc, char **argv) {
	string url = "http://127.0.0.1:8080/hessiantest/service";
	hessian::HttpConnection conn(url);

	test::IServiceProxy serviceProxy(conn);
	std::string sayHelloResult = serviceProxy.sayHello("steven");
	cout << "sayHelloResult: " << sayHelloResult << endl;

	test::Person person;
	person.uin = 1;

	struct timeval start, end;
	gettimeofday(&start, NULL);

	test::Property property = serviceProxy.getProperty(person, "test111");

	gettimeofday(&end, NULL);
	int timeuse = 1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec
			- start.tv_usec;

	cout << timeuse << "us" << endl;

	cout << "property.name is " << property.name << " property.car.name is "
			<< property.car.name << endl;
	cout << "property.i = " << property.i << " property.l = " << property.l
			<< " property.d = " << property.d << endl;
	for (std::vector<test::Car>::const_iterator p = property.cars.begin();
			p != property.cars.end(); ++p) {
		cout << p->name << " || " << p->desc << endl;
	}
}
